package com.leaf.u_spring.chapter12;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoOperations;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;


public class OrderOperationsimpl implements OrderOperations {

	@Autowired
	private MongoOperations mongo;		//注入MongoOperations
	@Override
	public List<Order> findOrderByType(String t) {
		String type = t.equals("NET") ? "WEB" : t;
		
		//创建查询
		Criteria where = Criteria.where("type").is(type);
		Query query = Query.query(where);
		
		//执行查询
		return mongo.find(query, Order.class);
	}

}
